﻿Rsd.define('Rsd.Faith.views.Header', {
    extend: 'Rsd.view.Header',
    requires: ['Rsd.control.Image',
        'Rsd.control.Label',
        'Rsd.control.ToolBarSeparator',
        'Rsd.control.Button'],
    xtype: 'f-header',
    border: false,
    height: 53,
    width: '100%',
    layout: 'hbox',
    cls: 'x-sys-header',
    items: [
        {
            id: '_head_logo',
            xtype: 'image',
            width: 60,
            height: '100%',
            style: {float: 'right'},
            //margin:'10 2 15 2',
            border: false,
            src: './resources/images/LOGO.PNG',
            cls: 'x-sys-header-logo'
        },
        {
            id: '_head_topic',
            xtype: 'label',
            width: 600,
            height: '100%',
            border: false,
            cls: 'x-sys-header-topic',
            text: Rsd.app.appTitle,
            label:{content:Rsd.app.subTitle,position:'right',width:140,style:{textAlign:'left',fontSize: '40%'}}
        },
        {
            xtype: 'label',
            width: 300,
            height: '100%',
            style:{fontSize: '130%'},
            label: {content:'当前位置：',width:100}
        },
        {
            xtype: 'button',
            width: 80,
            height: '100%',
            align: 'right',
            border: false,
            margin: '20 10 5 5',
            value: '退 出',
            handler: 'logout'
        },
        {
            xtype: 'link',
            width: 100,
            height: '100%',
            align: 'right',
            border: false,
            margin: '20 10 5 5',
            text: '✍修改密码',
            handler: 'btn_change_pwd'
        },
        {
            xtype: 'tbSeparator',
            align: 'right',
            height: '100%',
            margin: '20 5 10 5',
            cls: 'x-sys-header-info'
        },
        {
            id: '_head_user',
            xtype: 'label',
            width: 80,
            height: '100%',
            border: false,
            margin: '20 10 10 5',
            align: 'right',
            cls: 'x-sys-header-info',
            text: '♛' + Rsd.app.userName
        },
        {
            xtype: 'tbSeparator',
            align: 'right',
            height: '100%',
            margin: '20 5 10 5',
            cls: 'x-sys-header-info'
        },
        {
            id: '_head_date',
            xtype: 'label',
            width: 120,
            height: '100%',
            border: false,
            margin: '20 5 10 5',
            align: 'right',
            cls: 'x-sys-header-info',
            text: (new Date()).format("yyyy-MM-dd")
        }
    ],
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
    },
    btn_change_pwd:function btn_change_pwd()
    {
        alert('修改密码');
    },
    /*
     * */
    logout: function logout() {

        Rsd.showMessage("您确认退出系统？", [
            {
                btn: '确 认',
                fn: function () {
                    Rsd.app.getService("Verification.LogOut").requestJson({}, function (data) {
                        if (data.success) {
                            window.location = Rsd.app.indexUrl;
                        }
                        else {
                            Rsd.alert(data.msg);
                        }

                    });

                }
            }, {
                btn: '取 消',
                fn: function () {
                }
            }
        ]);
    },
    /*
    *
    * */
    setTitle: function setTitle(title)
    {
        if(this.items[2] instanceof  Rsd.control.Component)
        {
            this.items[2].setValue(title);
        }

    }

});